//
//  BHCircleRelationCollectionViewCell.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/7/13.
//

import UIKit

class BHCircleRelationCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var choseStateBtn: UIButton!
    
    @IBOutlet weak var relationBackView: UIView!
    
    @IBOutlet weak var iconImageView: UIImageView!
    
    @IBOutlet weak var name_label: UILabel!
    
    @IBOutlet weak var distance_label: UILabel!
    
    @IBOutlet weak var deleteBtn: UIButton!
    
    @IBOutlet weak var area_label: UILabel!
    
    var model: BHCirclePublishRelationInfoModel? {
        didSet {
            self.choseStateBtn.isSelected = model != nil
            self.relationBackView.isHidden = model == nil
            if model != nil {
                self.iconImageView.sd_setImage(with: URL.init(string: model!.relationPic), completed: nil)
                self.name_label.text = model?.relationName
                self.area_label.text = "\(model?.cityName ?? "")/\(model?.areaName ?? "")"
                if model?.type == 1 {
                    self.distance_label.isHidden = !BHLocationManager.shared.authed
                    self.distance_label.text = "\(model?.distance ?? "")km"
                }else {
                    self.distance_label.text = "开赛时间：\(model!.beginTime)"
                }
            }
        }
    }
    
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.relationBackView.addLayerCorner(4, 0, .white)
        self.iconImageView.addLayerCorner(4, 0, .white)
    }

}
